package entities.role;

import java.util.ArrayList;
import java.util.List;

import entities.concept.Concept;
/**
 * @deprecated
 * @author j55wu
 *
 */
public class RolePath {
	private List<Role> roles = new ArrayList<Role>();
	private Concept concept = null;
	private int offset = 0;
	
	public int getOffset() {
		return offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public Concept getConcept() {
		return concept;
	}

	public void setConcept(Concept concept) {
		this.concept = concept;
	}


	
	public RolePath() {
		
	}
	
	public List<Role> getRoles(){
		return this.roles;
	}
	
	public void rmRole(int index){
		this.roles.remove(index);
	}
	
	public void addRole(Role r){
		this.roles.add(r);
	}
	public RolePath(Concept c, int off) {
		concept = c;
		offset = off;
	}
	
	public int length() {
		return roles.size();
	}
	
	public RolePath newCopy(){
		RolePath myrp = new RolePath(null, this.offset);
		myrp.getRoles().addAll(this.roles);
		myrp.setConcept(this.concept);
		return myrp;
	}
	
	@Override
	public String toString(){
		String ret = "";
		ret += offset + "<";
		for(Role r:roles){
			ret += r.toString()+" ";
		}
		ret += "> ";
		ret += this.concept== null? "NULL" :concept.toString();
		return ret;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((concept == null) ? 0 : concept.hashCode());
		result = prime * result + offset;
		result = prime * result + ((roles == null) ? 0 : roles.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof RolePath))
			return false;
		RolePath other = (RolePath) obj;
		if (concept == null) {
			if (other.concept != null)
				return false;
		} else if (!concept.equals(other.concept))
			return false;
		if (offset != other.offset)
			return false;
		if (roles == null) {
			if (other.roles != null)
				return false;
		} else if (!roles.equals(other.roles))
			return false;
		return true;
	}
	
	
}
